import pywifi
from pywifi import const
# 判断是否连接wifi
def gic():
    # 创建wifi对象
    wifi =pywifi.PyWiFi()
    print(wifi)
    # 获取无线网卡
    iface = wifi.interfaces()[0]
    print(iface)
    print(iface.name()) # 获取无线网卡名称
    print(iface.status()) # 获取无线网卡连接状态
    if iface.status()==const.IFACE_CONNECTED:
        print("已连接")
    else:
        print("未链接")
# gic()
# 扫描附近的wifi
def bies():
    wifi = pywifi.PyWiFi()
    iface = wifi.interfaces()[0]
    iface.scan() # 获取扫描到的wifi
    result = iface.scan_results()
    print(result)
    for name in result:
        print(name)
        print("dddd")
bies()